home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-11-20 | 6.3 KB | 292 lines | [TEXT/ALFA] |
-
- # The commands so far are:
- # "thinkNumFiles" - Returns number of files in project.
- # "thinkFileName <index>|<name>" - Indexes start at '1'.
- # "thinkCompileFile <options> <filename>" - With no options, the action is to
- # compile the named file.
- # -2 tell Think not to open windows for output. Output is tossed.
- # -c precompile
- # -d dissasemble
- # -g run
- # -m make
- # -n use source file even for "make". This is because sending a project
- # object descriptor w/ the make command does nothing. Sending a
- # descriptor for an individual source file w/ the make command makes
- # the entire project. Don't ask me.
- # -p preprocess
- # -r <0|1> Wait for reply if '1', don't wait for '0'. Default for all
- # except precompile and disassemble, because these two are *supposed*
- # to return their text.
- # -s check syntax.
- # -u bring up-to-date.
- #
- #
- # "thinkCompileFile -m -n <any of the file names>" seems to make the entire project.
-
-
-
- # Get list of files in current project.
- proc projectFileList args {
- watchCursor
- set num [thinkNumFiles]
- set files {}
- if {[llength $args]} {
- for {set i 1} {$i<=$num} {incr i} {
- lappend files [thinkFileName -p $i]
- }
- } else {
- for {set i 1} {$i<=$num} {incr i} {
- lappend files [thinkFileName $i]
- }
- }
- return $files
- }
-
-
-
- # Think reference 2.0 support. From the shell:
- # dosc -c 'DanR' -k 'DanR' -e "'REF '" -s "PutScrap"
- # tells think reference to find and display the correct reference.
- # dosc -c 'DanR' -k 'DanR' -e 'TMPL' -s "PutScrap"
- # queries Think Reference for a function template and IM reference,
- # and displays information about the function in the background.
- # The following function interprets the selected text as a function
- # name and displays in an alert the function template.
- proc thinkReferenceTemplate args {
- if {[getPos] == [selEnd]} return
- catch {dosc -c 'DanR' -k 'DanR' -e 'TMPL' -s [getSelect]} res
- alertnote $res
- }
-
- proc add {} {
- thinkAddFile [lindex [winNames -f] 0]
- }
-
- proc addAndCompile {} {
- add
- compile
- }
-
- proc compile {} {
- watchCursor
- thinkCompileFile -c -r [lindex [winNames] 0]
- }
-
- proc checkSyntax {} {
- watchCursor
- thinkCompileFile -s -r [lindex [winNames] 0]
- }
-
- proc disassemble {} {
- watchCursor
- thinkCompileFile -d -r [lindex [winNames] 0]
- }
-
- proc preprocess {} {
- "Think isn't quite there yet..."
- return
- watchCursor
- thinkCompileFile -z [lindex [winNames] 0]
- }
-
- proc precompile {} {
- watchCursor
- thinkCompileFile -p -r [lindex [winNames] 0]
- }
-
- proc bringUpToDate {} {
- watchCursor
- thinkCompileFile -u -r
- }
-
- proc make {} {
- watchCursor
- thinkCompileFile -m -r
- }
-
- proc run {} {
- set name [checkRunning ThinkC KAHL thinkName]
- thinkCompileFile -g
- switchTo $name
- }
-
-
-
- #================================================================================
- set lastTrap {}
-
- proc insertTrapTemplate {} {
- global lastTrap
-
- if {![string length [checkRunning ThinkReference DanR referencePath]]} return
- set text [getSelect]
- if {![string length $text]} {
- if {[catch {prompt "Trap name:" $lastTrap} text]} return
- } else {
- deleteText [getPos] [selEnd]
- }
- set lastTrap $text
- if {[catch {thinkReference -t $text} out]} {
- alertnote "THINK Reference not running..."
- } else {
- insertText $out
- }
- }
-
- proc displayTrapTemplate {} {
- global lastTrap
-
- if {![string length [checkRunning ThinkReference DanR referencePath]]} return
- set text {}
- catch {set text [getSelect]}
- if {![string length $text]} {
- if {[catch {prompt "Trap name:" $lastTrap} text]} return
- }
- set lastTrap $text
- if {[catch {thinkReference -t $text} out]} {
- alertnote "THINK Reference not running..."
- } else {
- alertnote $out
- }
- }
-
- proc lookupTrap {} {
- global lastTrap
-
- if {![string length [checkRunning ThinkReference DanR referencePath]]} return
- set text {}
- catch {set text [getSelect]}
- if {![string length $text]} {
- if {[catch {prompt "Trap name:" $lastTrap} text]} return
- }
- set lastTrap $text
- if {[catch {thinkReference -l aesend $text}]} {
- alertnote "THINK Reference not running..."
- }
- }
-
- proc gotoReference {} {
- switchTo [checkRunning ThinkReference DanR referencePath]
- }
-
- menu -n "•265" {
- "gotoReference"
- "(-"
- "displayTrapTemplate"
- "insertTrapTemplate"
- "lookupTrap"
- }
-
- #================================================================================
-
-
- proc think {} {
- set name [checkRunning ThinkC KAHL thinkName]
- if {![string length $name]} return
- switchTo $name
- }
-
- proc findInNextFile {} {
- thinkFinf
- }
-
-
- # The 'Files' menu can instantiate itself from the THINK Project Manager if
- # it is running.
- menu -n "•300" {
- "/-think"
- "openHeader"
- "setIncludepath…"
- "(-"
- {menu -n {Project Files} {
- "getProjectFiles"}}
- "createProjectFileset"
- "(-"
- "/Kcompile"
- "checkSyntax"
- "findInNextFile"
- "(-"
- "add"
- "addAndCompile"
- "(-"
- "disassemble"
- "preprocess"
- "(precompile"
- "(-"
- "/UbringUpToDate"
- "make"
- "(-"
- "/Rrun"
- }
-
- proc getProjectFiles args {
- menu -n {Project Files} -m -p projFile [lsort [projectFileList -p]]
- }
-
- proc projFile {menu name} {
- edit [thinkFileName $name]
- }
-
-
- #===========================================================================
- # Add fileset.
- #===========================================================================
- proc createProjectFileset {} {
- global fileSets
- global currFileSet
-
- set name "Project"
- set fileSets($name) [projectFileList]
- addMenuItem -m fileSets $name
- set currFileSet $name
- }
-
- #================================================================================
-
- proc checkIncludepath {} {
- global includePath
- set bad 0
- if {![info exists includePath]} {return [setIncludepath]}
- foreach p [subVars $includePath] {
- if {![file exists $p]} {set bad 1}
- }
- if ($bad) setIncludepath
- }
-
- proc setIncludepath {} {
- global includePath HOME
-
- set includePath {}
-
- while {[string length [set path [get_directory]]]} {
- lappend includePath $path
- }
-
- set fid [open "$HOME:Tcl:SystemCode:definitions.tcl" "a"]
- puts $fid "set includePath \"$includePath\""
- close $fid
- }
-
- proc openHeader {} {
- global includePath
-
- checkIncludepath
- set path [subVars $includePath]
- set fname [getSelect]
- if {[string last ".h" $fname]=="-1"} {
- set fname ${fname}.h
- }
- set win [lindex [winNames -f] 0]
- if {[string match *:* $win]} {
- lappend path [file dirname $win]
- }
- foreach dir $path {
- if {[file exists $dir:$fname]} {
- edit $dir:$fname
- return
- }
- }
- beep
- message "No such header file"
- }
-